package com.neo.impatient.C14_PatternMatchingAndCaseClasses.C14_17_PartialFunctions


/**
  * 被包在花括号内的一组CASE语句就是偏函数,他是PartialFunction[A, B]的一个实例
  */
object PartialFunTest {




  def main(args: Array[String]): Unit = {
    val f: PartialFunction[Char, Int] = { case '+' => 1 ; case '-' => -1 }

    println(f('-'))
    //println(f('*'))

    if(f.isDefinedAt('a'))
      println("a is def")
    else
      println("a is not def")
  }
}
